package com.arcbbs.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

public class JsonUtils {
    public static final Logger logger = LoggerFactory.getLogger(JsonUtils.class);

    //对象转json
    public static String convertObjJson(Object obj) {
        return JSON.toJSONString(obj);
    }

    //json转对象
    public static <T> T convertJSON2Obj(String json, Class<T> classz) {
        return JSONObject.parseObject(json, classz);
    }

    //字符串数组转集合对象
    public static <T> List<T> convertJSONArrayList(String json, Class<T> tClass) {
        return JSONArray.parseArray(json, tClass);
    }
}
